package strategy;

/**
 * 策略模式
 * Comparable 对比对象
 * Comparator 策略模式
 *
 * 原则把可变的拿出来。
 */
//public class Strategy {
//    public static void main(String[] args) {
//
//        Sort sort = new Sort();
//        int [] ay = {99,1,3,4,32};
//        sort.sort(ay);
//        for(int i:ay){
//            System.out.println(i);
//        }
//    }
//}
class Cat implements Comparable<Cat>{
    private int height;
    private int width;
    public  Cat(int width, int height){
        this.width = width;
        this.height = height;
    }

    @Override
    public int compareTo(Cat o) {
        return width > o.width ? 1 : -1;
    }

    @Override
    public String toString() {
        return "Cat{" +
                "height=" + height +
                ", width=" + width +
                '}';
    }
}
class Dog implements Comparable<Dog>{
    private int height;
    private int width;
    public Dog(int width, int height){
        this.width = width;
        this.height = height;
    }

    @Override
    public int compareTo(Dog o) {
        return width > o.width ? 1 : -1;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "height=" + height +
                ", width=" + width +
                '}';
    }
}



public class Strategy {
    public static void main(String[] args) {

        Comparable [] comparable = {
          new Cat(211,2),
          new Cat(33,44)
        };

        new ComparaableSort().sort(comparable);

        for(Comparable item:comparable){
            System.out.println(item);
        }
    }
}